package nbcp.base.utils

/**
 * Created by yuxh on 2019/1/8
 */

object ValidateUtil{
    fun password_validate(password:String ):String{
        if( password.length <4) return "密码至少4位"

        var letter = false;
        var digit = false;
        var special = false;
        password.forEach {
            if(!letter &&  it.isLetter()){
                letter = true;
                return@forEach;
            }
            if( !digit && it.isDigit()){
                digit = true;
                return@forEach
            }

            if( !special && !it.isLetterOrDigit()){
                special = true;
                return@forEach
            }
        }

        if( letter == false){
            return "密码必须包含字母"
        }
        if( digit == false){
            return "密码必须包含数字"
        }
//        if(special == false){
//            return "密码必须包含特殊字符"
//        }

        return "";
    }

}